package com.huiquan.foundation.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import com.huiquan.analysis.service.AnalysisCheckExportFileService;
import com.huiquan.management.service.MigrateService;
import com.huiquan.management.service.PageRoleService;

@Component
public class StartupInit implements ApplicationListener<ContextRefreshedEvent> {

	@Autowired
	private MigrateService migrateService;
	@Autowired
	private PageRoleService pageRoleService;
	@Autowired
	private AnalysisCheckExportFileService analysisCheckExportFileService;
	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {

		// 只在root application context初始化完成后调用
		if (event.getApplicationContext().getParent() == null) {

			// 对数据迁移的地址初始化
			migrateService.init();

			// 初始化权限
			pageRoleService.initRole();

			// 对主诉现病史导出文件大小进行校验的初始化
			analysisCheckExportFileService.initAnalysisCheckParam();
		}
	}


}
